package com.zerui.manager.deviceTouchSync.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.zerui.manager.deviceTouchSync.DeviceTouchSync;
import io.swagger.annotations.ApiModel;
import lombok.*;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * 设备实体类
 *
 * @author pyzhang
 * @since 2024-04-11
 */
@ApiModel("远程设备落地同步记录")
@Data
@ToString
@Accessors(chain = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "tb_device_touch_sync",autoResultMap = true)
public class DeviceTouchSyncDO {

    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 同步时间
     */
    private LocalDateTime syncTime;
    /**
     * 同步状态 1：正在同步  2：完成同步  -1：同步出错
     */
    private Integer syncStatus;
    /**
     * 同步备注消息
     */
    private String syncRemark;
    /**
     * 同步源  1：IoT 2：ICC 
     */
    private Integer syncFrom;
    /**
     * 同步源数据
     */
    private String syncFromData;
    /**
     * 同步新增的数据
     */
    private String syncAddData;
    /**
     * 同步更新的数据
     */
    private String syncUpdateData;
    /**
     * 同步删除的数据
     */
    private String syncDeleteData;
    /**
     * 同步操作人
     */
    private String syncOperator;

    public static DeviceTouchSyncDO of(DeviceTouchSync deviceTouchSync) {
        DeviceTouchSyncDO deviceTouchSyncDO = new DeviceTouchSyncDO();
        deviceTouchSyncDO.id = deviceTouchSync.getId();
        deviceTouchSyncDO.syncTime = deviceTouchSync.getSyncTime();
        deviceTouchSyncDO.syncStatus = deviceTouchSync.getSyncStatus();
        deviceTouchSyncDO.syncRemark = deviceTouchSync.getSyncRemark();
        deviceTouchSyncDO.syncFrom = deviceTouchSync.getSyncFrom();
        deviceTouchSyncDO.syncFromData = deviceTouchSync.getSyncFromData();
        deviceTouchSyncDO.syncAddData = deviceTouchSync.getSyncAddData();
        deviceTouchSyncDO.syncUpdateData = deviceTouchSync.getSyncUpdateData();
        deviceTouchSyncDO.syncDeleteData = deviceTouchSync.getSyncDeleteData();
        deviceTouchSyncDO.syncOperator = deviceTouchSync.getSyncOperator();
        return deviceTouchSyncDO;
    }

    public DeviceTouchSync toDomain() {
        DeviceTouchSync deviceTouchSync = new DeviceTouchSync();
        deviceTouchSync.setId(this.id);
        deviceTouchSync.setSyncTime(this.syncTime);
        deviceTouchSync.setSyncStatus(this.syncStatus);
        deviceTouchSync.setSyncRemark(this.syncRemark);
        deviceTouchSync.setSyncFrom(this.syncFrom);
        deviceTouchSync.setSyncFromData(this.syncFromData);
        deviceTouchSync.setSyncAddData(this.syncAddData);
        deviceTouchSync.setSyncUpdateData(this.syncUpdateData);
        deviceTouchSync.setSyncDeleteData(this.syncDeleteData);
        deviceTouchSync.setSyncOperator(this.syncOperator);
        return deviceTouchSync;
    }
}
